Skip to content

Add warning/error handling for --include-external #1293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

eseidelGoogle
Copy link
Contributor

@eseidelGoogle eseidelGoogle commented Dec 14, 2016

This makes --include-external a bit harder to use incorrectly (with surprising results).

Cases I would like to test (but don't see an easy way how would include):

  1. --external-library asldkfjsdf hit the "warn no libraries found" case
  2. --external-library dart hit the "multiple libraries found" case
  3. --external-library dartdoc.dart hit the "library already found" case

I looked at adding tests to test/dartdoc_test.dart, but those do not seem set up to handle logging. I looked briefly ad breaking this logic out into its own function, but it wasn't clear how to provide the necessary AnalysisContext with sources.

I've been able to trigger the first two test cases manually, but not yet seen the 3rd.

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Dec 14, 2016
Copy link
Member

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts...

List<Source> matchedSources = context.librarySources
.where((library) => matchesLibrary(includeExternal, library));
if (matchedSources.isEmpty) {
print(" warning: $quotedArgString -- " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: + not needed here. adjacent String literals auto-concat. Is nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

for (String includeExternal in includeExternals) {
var quotedArgString = "'--include-external $includeExternal'";
List<Source> matchedSources = context.librarySources
.where((library) => matchesLibrary(includeExternal, library));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add .toList() here – make sure we don't re-iterate the iterable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would it mean to re-iterate the iterable? Is this a general pattern we should have the analyzer warn about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I should write-up a little dartpad thing to show this.

@eseidelGoogle
Copy link
Contributor Author

Thanks for the comments! I actually think I should drop this pull request. I mostly was just in the code and wrote it up for funsies. What @keertip provided in #1289 was sufficient for Flutter's needs and I'm likely not going to find time to take this to completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants